package com.kube.gateway.core.router.domain.dto;

import com.kube.gateway.core.router.domain.entity.RouterEntity;
import com.kube.gateway.core.utils.JsonUtil;

import java.util.List;

public class RouteDefinitionDto {
    private Long id;
    private String name;
    private String desc;
    private String uri;
    private List<PredicateDto> predicateDtoList;
    private List<FilterDto> filterDtoList;
    private Long updateId;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public List<PredicateDto> getPredicateDtoList() {
        return predicateDtoList;
    }

    public void setPredicateDtoList(List<PredicateDto> predicateDtoList) {
        this.predicateDtoList = predicateDtoList;
    }

    public List<FilterDto> getFilterDtoList() {
        return filterDtoList;
    }

    public void setFilterDtoList(List<FilterDto> filterDtoList) {
        this.filterDtoList = filterDtoList;
    }

    public Long getUpdateId() {
        return updateId;
    }

    public void setUpdateId(Long updateId) {
        this.updateId = updateId;
    }

    public RouterEntity toEntity(){
        RouterEntity routerEntity = new RouterEntity();
        routerEntity.setId(id);
        routerEntity.setName(name);
        routerEntity.setFilters(JsonUtil.obj2String(filterDtoList));
        routerEntity.setPredicates(JsonUtil.obj2String(predicateDtoList));
        routerEntity.setCreateId(updateId);
        routerEntity.setUpdateId(updateId);
        return routerEntity;
    }
}
